import request from '@/utils/request'
const baseUrl = '/ota'
export class OtaApi {
    // 上传文件
    static uploadFile(data: any, onUploadProgress: (progressEvent: any) => void, cancelToken:any) {
        return request(`${baseUrl}/file_upload`, {
            method: 'POST',
            data,
            headers: {
                'Content-Type': 'multipart/form-data',
            },
            onUploadProgress: onUploadProgress,
            cancelToken: cancelToken
        })
    }

    //获取固件文件信息
    static reqGetFileInfo(data:any){
        return request(`${baseUrl}/fw_info`,{
            method:"POST",
            data
        })
    }

    //固件升级
    static reqUpgradeFirmware(data:any){
        return request(`${baseUrl}/upgrade`,{
            method:"POST",
            data
        })
    }

    //查询固件升级状态
    static reqGetUpgradeStatus(data:any){
        return request(`${baseUrl}/upgrade_status`,{
            method:"POST",
            data
        })
    }

    //裸包升级
    static reqUpgradeFirmwareByRaw(data:any){
        return request(`${baseUrl}/upgrade_bare`,{
            method:"POST",
            data
        })
    }

    //查询裸包升级状态
    static reqGetUpgradeStatusByRaw(data:any){
        return request(`${baseUrl}/upgrade_status_bare`,{
            method:"POST",
            data
        })
    }
}
